//
//  UIBarButtonItem+LIUCustomItem.m
//  EasyNotes
//
//  Created by 劉裕 on 6/5/2016.
//  Copyright © 2016年 劉裕. All rights reserved.
//

#import "UIBarButtonItem+LIUCustomItem.h"

@implementation UIBarButtonItem (LIUCustomItem)

+ (UIBarButtonItem *)barButtonItemWithImage:(UIImage *)image HighImage:(UIImage *)highImage target:(id)target action:(SEL)action {
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setBackgroundImage:image forState:UIControlStateNormal];
    [button setBackgroundImage:highImage forState:UIControlStateHighlighted];
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    CGRect frame = button.frame;
    frame.size = button.currentBackgroundImage.size;
    button.frame = frame;
    return [[UIBarButtonItem alloc] initWithCustomView:button];
}
@end
